Skip to content

fix(flows): correct save_workflow + workflow_builder contract text (disarm/create accuracy)#4904

Merged
graycyrus merged 3 commits into
tinyhumansai:mainfrom
graycyrus:fix/flows-builder-contract-accuracy
Jul 15, 2026
Merged

fix(flows): correct save_workflow + workflow_builder contract text (disarm/create accuracy)#4904
graycyrus merged 3 commits into
tinyhumansai:mainfrom
graycyrus:fix/flows-builder-contract-accuracy

Conversation

@graycyrus

@graycyrus graycyrus commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Two small contract-accuracy fixes in workflow_builder (tinyflows agent) — no behavior/tool-belt changes, only descriptive text + one bug where an explanatory log was silently dropped.

Fix 1 — save_workflow description/comments stale after #4889 (+ dropped disarm logs)

#4889 made flows_update auto-disable a flow whenever its trigger transitions from manual to an automatic kind (schedule/webhook/app_event) on an already-enabled flow — but never on its own for an existing automatic→automatic re-save.

  • SaveWorkflowTool::description() (src/openhuman/flows/builder_tools.rs) still said save_workflow "never changes the flow's enabled state" — now corrected to state the auto-disarm behavior.
  • The inline comment above the "now LIVE" warning still said flows_update "preserves whatever enabled state the flow already had" (unconditionally) — corrected to describe the disarm-on-transition case first, then the preserved-state case.
  • save_workflow extracted outcome.value from flows_update's RpcOutcome but dropped outcome.logs — so when a save disarmed a flow, the model never saw flows_update's explanation ("Flow was auto-disabled because its trigger changed from manual to automatic..."). Now threaded into the tool's warnings array (skipping the boilerplate "flow updated: <id>" line, which just duplicates fields already in the response).

Fix 2 — workflow_builder claimed it "can never create a flow"

agent.toml's when_to_use and [tools] comments, plus prompt.md's invariants section, claimed the agent "can never create a new flow" / "has no tool that does" — false: create_workflow and duplicate_flow are on the belt (named list in agent.toml). They're safe because every flow they create is force-disabled at creation (CreateWorkflowTool, duplicate_flow's born-disabled clone). The contradiction was visible within prompt.md itself (the invariants section at the top said "cannot create a flow", while a later section accurately described create_workflow/duplicate_flow).

Updated the descriptive text in both files to state the accurate contract: the agent can create a flow on explicit ask, but every created flow is born DISABLED, and it can never enable one. No change to the tool belt or to the born-disabled persistence behavior.

Files changed

  • src/openhuman/flows/builder_tools.rsSaveWorkflowTool::description(), inline comment, thread outcome.logs into warnings.
  • src/openhuman/flows/builder_tools_tests.rs — new regression test save_workflow_surfaces_auto_disarm_warning_on_manual_to_automatic_transition.
  • src/openhuman/flows/agents/workflow_builder/agent.tomlwhen_to_use, [tools]/sandbox comments.
  • src/openhuman/flows/agents/workflow_builder/prompt.md — invariants section + save_workflow guidance paragraph.
  • src/openhuman/flows/agents/workflow_builder/builder_prompt.rs — extended standing_prompt_teaches_plain_language_and_readonly_memory with negative assertions against the stale "never create a flow" phrasing and positive assertions for the accurate create_workflow/born-disabled contract.

Test plan

  • GGML_NATIVE=OFF cargo check --manifest-path Cargo.toml — clean.
  • GGML_NATIVE=OFF cargo test --lib openhuman::flows:: — 384 passed, 0 failed.
  • New test save_workflow_surfaces_auto_disarm_warning_on_manual_to_automatic_transition passes — seeds an enabled manual-trigger flow, saves a schedule-trigger graph onto it, asserts the flow ends up disabled and the disarm log appears in warnings.
  • Extended standing_prompt_teaches_plain_language_and_readonly_memory passes — asserts the stale "can never create a flow" phrasing is gone and the accurate create_workflow/born-disabled contract is taught.
  • cargo fmt clean (no diff).

Summary by CodeRabbit

  • Improvements
    • New flows are born DISABLED by default and require explicit user confirmation before any activation.
    • Workflow creation/duplication/saving behavior is now more tightly gated for safety and persistence.
    • Saving can automatically auto-disable flows when triggers move from manual → automatic, with re-arming possible when remaining automatic.
    • Save actions now surface clearer warnings explaining auto-disarm events.
  • Bug Fixes
    • Improved persistence and enabled-state handling across manual→automatic trigger transitions.
  • Tests
    • Added regression coverage for auto-disable behavior and warning contents.

…ate accuracy) + surface disarm logs

- save_workflow's tool description and inline comment claimed it "never
  changes the flow's enabled state" — stale since tinyhumansai#4889 made flows_update
  auto-disable a flow on a manual->automatic trigger transition. Update both
  to state the disarm behavior accurately.
- save_workflow dropped flows_update's outcome.logs, so the model never saw
  the "auto-disabled because trigger changed manual->automatic" explanation.
  Thread outcome.logs into the returned warnings (minus the boilerplate
  "flow updated: <id>" line).
- workflow_builder's agent.toml (when_to_use + [tools] comments) and
  prompt.md claimed the agent "can never create a new flow" / had "no tool
  that does" — false: create_workflow/duplicate_flow are on the belt and
  safe because created flows are always born disabled. Corrected the
  descriptive text; tool belt and born-disabled behavior are unchanged.

Tests: extended save_workflow test coverage with a disarm-on-save regression
test asserting flows_update's log surfaces in the response warnings; extended
builder_prompt.rs's standing-prompt contract test with negative assertions
against the stale "never create a flow" phrasing and positive assertions for
the accurate create_workflow/born-disabled contract.
@graycyrus
graycyrus requested a review from a team July 15, 2026 13:22
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cf57e29f-4afa-4074-862e-4105ae1f5b78

📥 Commits

Reviewing files that changed from the base of the PR and between 6053088 and 47da50f.

📒 Files selected for processing (2)
  • src/openhuman/flows/agents/workflow_builder/prompt.md
  • src/openhuman/flows/builder_tools_tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/openhuman/flows/builder_tools_tests.rs
  • src/openhuman/flows/agents/workflow_builder/prompt.md

📝 Walkthrough

Walkthrough

The workflow builder prompt now requires explicit creation requests and disabled initial flows. SaveWorkflowTool surfaces trigger-disarm logs, documents automatic-trigger behavior, and is regression-tested for persistent disabling after a manual-to-schedule transition.

Changes

Workflow builder safety

Layer / File(s) Summary
Builder creation and persistence contract
src/openhuman/flows/agents/workflow_builder/agent.toml, src/openhuman/flows/agents/workflow_builder/prompt.md, src/openhuman/flows/agents/workflow_builder/builder_prompt.rs
Agent guidance requires explicit creation or duplication requests, disabled initial flows, user-gated persistence, and accurate standing-prompt wording.
Save-time trigger handling
src/openhuman/flows/builder_tools.rs, src/openhuman/flows/builder_tools_tests.rs
SaveWorkflowTool reports explanatory update logs as warnings and tests auto-disabling when a manual trigger becomes schedule-based.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SaveWorkflowTool
  participant flows_update
  participant FlowStorage
  SaveWorkflowTool->>flows_update: Save graph with automatic trigger
  flows_update->>FlowStorage: Persist disabled enabled-state
  flows_update-->>SaveWorkflowTool: Return disarm logs
  SaveWorkflowTool-->>SaveWorkflowTool: Append logs to warnings
Loading

Possibly related PRs

Suggested labels: bug, rust-core, agent

Poem

I’m a rabbit with workflows tucked under my ear,
New flows sleep disabled, safe and clear.
A trigger turns automatic—off goes the spark,
Warnings hop back from the update’s remark.
Tests guard the burrow, steady and bright. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: it corrects save_workflow and workflow_builder contract text regarding automatic disarming and flow creation capabilities.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. bug rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. labels Jul 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6053088359

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +11 to +13
You **can** create a new flow (`create_workflow`) or clone one
(`duplicate_flow`), but only when the user explicitly asks — and every flow
you create is always born **DISABLED**. Enabling a flow is not a tool you

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clarify explicit new-flow saves

When the user explicitly asks the builder to create/save a brand-new flow and there is no existing flow_id, this new permission conflicts with the still-present save-only guidance in the same prompt: it calls save_workflow the “ONE persistence tool” and says if there is “no flow yet” to hand back the proposal instead of creating. Since prompt.md is the agent’s system prompt and create_workflow is actually on the belt, the model can still refuse or skip the new create path for exactly the scenario this commit is trying to enable; make the save section route explicit new-flow requests to create_workflow/duplicate_flow and reserve save_workflow for existing flows.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 47da50f — split the "user says save it" guidance in prompt.md into existing-flow (save_workflow) vs brand-new-flow (create_workflow/duplicate_flow) cases, so an explicit "create and save this as a new flow" ask now routes to create_workflow instead of falling through to propose-only.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/openhuman/flows/builder_tools_tests.rs (1)

1776-1822: 📐 Maintainability & Code Quality | 🔵 Trivial

Test doesn't verify the boilerplate line is actually excluded.

The test asserts an "auto-disabled" warning is present, but never asserts the redundant "flow updated: {flow_id}" boilerplate is absent from warnings — the specific exclusion behavior this PR claims to add. See the related comment on src/openhuman/flows/builder_tools.rs#L3391-3402 for the consolidated fix.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openhuman/flows/builder_tools_tests.rs` around lines 1776 - 1822, The
test
save_workflow_surfaces_auto_disarm_warning_on_manual_to_automatic_transition
must also verify that warnings excludes the redundant “flow updated: {flow_id}”
boilerplate. Keep the existing auto-disabled warning assertion and add an
assertion over parsed["warnings"] confirming no warning contains the
flow-updated message for flow_id.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/openhuman/flows/builder_tools_tests.rs`:
- Around line 1776-1822: The test
save_workflow_surfaces_auto_disarm_warning_on_manual_to_automatic_transition
must also verify that warnings excludes the redundant “flow updated: {flow_id}”
boilerplate. Keep the existing auto-disabled warning assertion and add an
assertion over parsed["warnings"] confirming no warning contains the
flow-updated message for flow_id.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1445408-7c5a-4ce9-a03e-ab0bcea1f320

📥 Commits

Reviewing files that changed from the base of the PR and between 0e86b85 and 6053088.

📒 Files selected for processing (5)
  • src/openhuman/flows/agents/workflow_builder/agent.toml
  • src/openhuman/flows/agents/workflow_builder/builder_prompt.rs
  • src/openhuman/flows/agents/workflow_builder/prompt.md
  • src/openhuman/flows/builder_tools.rs
  • src/openhuman/flows/builder_tools_tests.rs

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 15, 2026
…ngs (addresses @coderabbitai on builder_tools_tests.rs:1776-1822)

CodeRabbit nitpick: the auto-disarm regression test asserted the
"auto-disabled" warning was present but never asserted the redundant
"flow updated: <id>" boilerplate line was excluded — the specific
filtering behavior SaveWorkflowTool::execute claims to add.
…in prompt.md (addresses @chatgpt-codex-connector on prompt.md:13)

The invariants section already said the agent CAN create_workflow/
duplicate_flow on explicit ask, but the "Saving your work" section
below it only described save_workflow and told the agent to fall back
to propose-only when there's no flow_id yet — even when the user
explicitly asked to create-and-save a brand-new flow. Split the
"user says save it" guidance into existing-flow (save_workflow) vs
brand-new-flow (create_workflow/duplicate_flow) cases so the model
doesn't skip the create path for exactly the scenario this PR enables.
@graycyrus

Copy link
Copy Markdown
Contributor Author

Addressed CodeRabbit's nitpick (review 4704530374) on builder_tools_tests.rs: save_workflow_surfaces_auto_disarm_warning_on_manual_to_automatic_transition now also asserts that warnings excludes the redundant "flow updated: " boilerplate line, not just that the auto-disabled warning is present. Fixed in 4ae009d.

@graycyrus
graycyrus merged commit 5ba512b into tinyhumansai:main Jul 15, 2026
22 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Team Openhuman Jul 15, 2026
senamakel pushed a commit to M3gA-Mind/openhuman that referenced this pull request Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. bug rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant